﻿//********************************************************************************//
//创建日期：<创建日期，2017-6-16>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：立成财务接口Model
//********************************************************************************//
using System;
using System.Collections.Generic;
using YXYLCommon;
using System.Data;

namespace Entity
{
    [Serializable]
    /// <summary>
    /// 立成财务接口
    /// </summary>
    public class QSZWLCCWJK : BaseModel
    {
        public QSZWLCCWJK()
        {

        }

        public string S_GONGZUONY { get; set; }
        public string S_ZHAIYAO { get; set; }
        public string S_KEMUDM { get; set; }
        public string S_FAPIAOBH { get; set; }
        public string S_JIESUANFS { get; set; }
        public string S_PIAOJUBH { get; set; }
        public string S_BIZHONG { get; set; }
        public string S_HESUANDM { get; set; }
        public string S_KEHUDM { get; set; }
        public string S_KEHUMC { get; set; }
        public string S_RENYUANDM { get; set; }
        public string S_DANJUBH { get; set; }
        public string S_PINGZHENGBH { get; set; }
        public string S_ZHIDAN { get; set; }
        public string S_FUHE { get; set; }
        public string S_XIANGMDM { get; set; }
        public string S_XIANGMUMC { get; set; }

        public string S_BEIZHU { get; set; }
        public DbInt I_PINGZHENGLXBH { get; set; }
        public DbInt I_SHOUFUZJLX { get; set; }
        public DbInt I_XIANYINZJLX { get; set; }
        public DbInt I_FENLUSXH { get; set; }
        public DbInt I_FUJIAN { get; set; }
        public DbDecimal N_JIEFANGJE { get; set; }
        public DbDecimal N_DAIFANGJE { get; set; }
        public DbDecimal N_WAIBIJFJE { get; set; }
        public DbDecimal N_WAIBIDFJE { get; set; }
        public DbDecimal N_HUILV { get; set; }
        public DbDecimal N_JIEFANGSL { get; set; }
        public DbDecimal N_DAIFANGSL { get; set; }
        public DbDecimal N_DANJIA { get; set; }
        public DbDateTime D_PINGZHENGLRRQ { get; set; }
        public DbDateTime D_SHIJIRQ { get; set; }

        public override BaseModel ToObject(System.Data.DataRow row)
        {
            this.IsExists = true;
            this.S_BEIZHU = row.Table.Columns.Contains("S_BEIZHU") ? Convert.ToString(row["S_BEIZHU"]) : null;
            this.S_BIZHONG = row.Table.Columns.Contains("S_BIZHONG") ? Convert.ToString(row["S_BIZHONG"]) : null;
            this.S_DANJUBH = row.Table.Columns.Contains("S_DANJUBH") ? Convert.ToString(row["S_DANJUBH"]) : null;
            this.S_FAPIAOBH = row.Table.Columns.Contains("S_FAPIAOBH") ? Convert.ToString(row["S_FAPIAOBH"]) : null;
            this.S_FUHE = row.Table.Columns.Contains("S_FUHE") ? Convert.ToString(row["S_FUHE"]) : null;
            this.S_GONGZUONY = row.Table.Columns.Contains("S_GONGZUONY") ? Convert.ToString(row["S_GONGZUONY"]) : null;
            this.S_HESUANDM = row.Table.Columns.Contains("S_HESUANDM") ? Convert.ToString(row["S_HESUANDM"]) : null;
            this.S_JIESUANFS = row.Table.Columns.Contains("S_JIESUANFS") ? Convert.ToString(row["S_JIESUANFS"]) : null;
            this.S_KEHUDM = row.Table.Columns.Contains("S_KEHUDM") ? Convert.ToString(row["S_KEHUDM"]) : null;
            this.S_KEHUMC = row.Table.Columns.Contains("S_KEHUMC") ? Convert.ToString(row["S_KEHUMC"]) : null;
            this.S_KEMUDM = row.Table.Columns.Contains("S_KEMUDM") ? Convert.ToString(row["S_KEMUDM"]) : null;
            this.S_PIAOJUBH = row.Table.Columns.Contains("S_PIAOJUBH") ? Convert.ToString(row["S_PIAOJUBH"]) : null;
            this.S_PINGZHENGBH = row.Table.Columns.Contains("S_PINGZHENGBH") ? Convert.ToString(row["S_PINGZHENGBH"]) : null;
            this.S_RENYUANDM = row.Table.Columns.Contains("S_RENYUANDM") ? Convert.ToString(row["S_RENYUANDM"]) : null;
            this.S_XIANGMDM = row.Table.Columns.Contains("S_XIANGMDM") ? Convert.ToString(row["S_XIANGMDM"]) : null;
            this.S_XIANGMUMC = row.Table.Columns.Contains("S_XIANGMUMC") ? Convert.ToString(row["S_XIANGMUMC"]) : null;
            this.S_ZHAIYAO = row.Table.Columns.Contains("S_ZHAIYAO") ? Convert.ToString(row["S_ZHAIYAO"]) : null;
            this.S_ZHIDAN = row.Table.Columns.Contains("S_ZHIDAN") ? Convert.ToString(row["S_ZHIDAN"]) : null;

            if(row.Table.Columns.Contains("I_FENLUSXH"))
            {
                this.I_FENLUSXH =DbInt.Parse(row["I_FENLUSXH"]);
            }
            if (row.Table.Columns.Contains("I_FUJIAN"))
            {
                this.I_FUJIAN = DbInt.Parse(row["I_FUJIAN"]);
            }
            if (row.Table.Columns.Contains("I_PINGZHENGLXBH"))
            {
                this.I_PINGZHENGLXBH = DbInt.Parse(row["I_PINGZHENGLXBH"]);
            }
            if (row.Table.Columns.Contains("I_SHOUFUZJLX"))
            {
                this.I_SHOUFUZJLX = DbInt.Parse(row["I_SHOUFUZJLX"]);
            }
            if (row.Table.Columns.Contains("I_XIANYINZJLX"))
            {
                this.I_XIANYINZJLX = DbInt.Parse(row["I_XIANYINZJLX"]);
            }
            if (row.Table.Columns.Contains("N_DAIFANGJE"))
            {
                this.N_DAIFANGJE = DbDecimal.Parse(row["N_DAIFANGJE"]);
            }
            if (row.Table.Columns.Contains("N_DAIFANGSL"))
            {
                this.N_DAIFANGSL = DbDecimal.Parse(row["N_DAIFANGSL"]);
            }
            if (row.Table.Columns.Contains("N_DANJIA"))
            {
                this.N_DANJIA = DbDecimal.Parse(row["N_DANJIA"]);
            }
            if (row.Table.Columns.Contains("N_HUILV"))
            {
                this.N_HUILV = DbDecimal.Parse(row["N_HUILV"]);
            }
            if (row.Table.Columns.Contains("N_JIEFANGJE"))
            {
                this.N_JIEFANGJE = DbDecimal.Parse(row["N_JIEFANGJE"]);
            }
            if (row.Table.Columns.Contains("N_JIEFANGSL"))
            {
                this.N_JIEFANGSL = DbDecimal.Parse(row["N_JIEFANGSL"]);
            }
            if (row.Table.Columns.Contains("N_WAIBIDFJE"))
            {
                this.N_WAIBIDFJE = DbDecimal.Parse(row["N_WAIBIDFJE"]);
            }
            if (row.Table.Columns.Contains("N_WAIBIJFJE"))
            {
                this.N_WAIBIJFJE = DbDecimal.Parse(row["N_WAIBIJFJE"]);
            }
            this.D_PINGZHENGLRRQ = DbDateTime.Parse("D_PINGZHENGLRRQ");
            this.D_SHIJIRQ = DbDateTime.Parse("D_SHIJIRQ");
            return this;
        }
    }

    /// <summary>
    /// 凭证信息
    /// </summary>
    public class QSZWLCCWJK_PZXX : BaseModel
    {
        public QSZWLCCWJK_PZXX()
        {

        }
        public int I_PINGZHENGLXBH { get; set; }
        public string S_PINGZHENGLX { get; set; }
        public override BaseModel ToObject(System.Data.DataRow row)
        {
            this.IsExists = true;

            if (row.Table.Columns.Contains("I_PINGZHENGLXBH"))
            {
                this.I_PINGZHENGLXBH = Convert.ToInt32(row["I_PINGZHENGLXBH"]);
            }
            if (row.Table.Columns.Contains("S_PINGZHENGLX"))
            {
                this.S_PINGZHENGLX = Convert.ToString(row["S_PINGZHENGLX"]);
            }
            return this;
        }
    }
    public class DALQSZWLCCWJK : BaseDAL
    {
        public DALQSZWLCCWJK()
        {

        }
        protected override void fillSaveProc(BaseModel model)
        {

        }


        /// <summary>
        /// 生成数据
        /// </summary>
        /// <param name="zwym"></param>
        /// <returns></returns>
        public DbCmdResult SC(int zwym,int wtype)
        {
            if (wtype == 0)
            {
                dbProc.Init("P_YSZW_LCCWJK_SC");
            }
            else
            {
                dbProc.Init("P_DXSZW_LCCWJK_SC");
            }
            dbProc.AddParameter("V_ZWYM", zwym);
            dbProc.AddParameter("V_WTYPE", wtype);
            return CommonService.Ini().ExcuteProc(dbProc);
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        public List<QSZWLCCWJK> HQ(int zwym,int pzlxbh, int wtype)
        {
            dbProc.Init("P_DXSZW_LCCWJK_HQ");
            dbProc.AddParameter("V_ZWYM", zwym);
            dbProc.AddParameter("V_PZLXBH", pzlxbh);
            dbProc.AddParameter("V_WTYPE", wtype);
            return CommonService.Ini().GetList<QSZWLCCWJK>(dbProc);
        }
        /// <summary>
        /// 获取凭证信息
        /// </summary>
        public List<QSZWLCCWJK_PZXX> PZXX_HQ(int zwym,int wtype)
        {
            dbProc.Init("P_DXSZW_LCCWJK_PZXXHQ");
            dbProc.AddParameter("V_ZWYM", zwym);
            dbProc.AddParameter("V_WTYPE", wtype);
            return CommonService.Ini().GetList<QSZWLCCWJK_PZXX>(dbProc);
        }

        /// <summary>
        /// 导入立成(执行SQL存储过程插数据)
        /// </summary>
        public DbCmdResult DRLC(int wtype,int zwym,List<DbProcObject> poList)
        {
            foreach (var item in poList)
            {
                item.ProcName = "p_planwater_drlc_insert";
            }
            DbProcObject first = new DbProcObject();
            first.Init("p_planwater_drlc_del");
            first.AddSQLParameter("@wtype", wtype);
            first.AddSQLParameter("@zwym",zwym);
            poList.Insert(0, first);
            return CommonService.IniSQL(eSQLDB.lccwjhys.ToString()).ExcuteProcSqlList(poList);
        }
        /// <summary>
        /// 提取oracle数据
        /// </summary>
        public DataSet DRLC_XXTQ(int zwym, int wtype, string caozuor)
        {
            dbProc.Init("P_DXSZW_LCCWJK_DRLC");
            dbProc.AddParameter("V_ZWYM", zwym);
            dbProc.AddParameter("V_WTYPE", wtype);
            dbProc.AddParameter("V_CAOZUOR", caozuor);
            return CommonService.Ini().GetOracleDataSet(dbProc);
        }
    }

}